package com.xzl.xep.exception;

import java.io.PrintWriter;
import java.io.StringWriter;

public class BusinessException extends RuntimeException {

	private static final long serialVersionUID = 1L;
	
	private String message;
	private String view;
	private boolean isView = false;

	public BusinessException() {
		super();
	}
	
	public BusinessException(String message) {
		super(message);
		this.message = message;
	}
	
	public String getDetailMessage(Exception e){
		StringWriter out = new StringWriter();
		e.printStackTrace(new PrintWriter(out));
		return out.toString();
	}
	
	public String toJsonStr(){
		return "{\"errMsg\":\""+message+"\"}";
	}
	
	public String toView(){
		return view;
	}
	
	public void toView(String view){
		this.view = view;
		this.isView = true;
	}
	
	public boolean isToView(){
		return this.isView;
	}
	
	public Object toJson(){
		return null;
	}
}
